<!-- navbar start -->
<script>
    $(function () {
        $loginName = $(".loginName");
        $logout = $(".logout");
        $history = $(".historyOrder");
        $login = $(".login");
        $regist = $(".register");
        $.post("/Pizza_war_exploded/CartServlet/GetCartCount",{},
        function (data){
            if (data!=0){
                $(".count").html(data);
            }else{
                $(".count").css("display","none")
            }
        });
        $.get("/Pizza_war_exploded/User/findOne",{},
            function (data) {
                // data是查询到的登录的用户，可能是null
                if (data.flag){ // 登录状态
                    $logout.css("display", "block");
                    $loginName.css("display", "block");
                    $history.css("display", "block");
                    $login.css("display", "none");
                    $regist.css("display", "none");
                    $(".loginName").html(data.data.name);
                }else { // 未登录状态
                    $logout.css("display", "none");
                    $loginName.css("display", "none");
                    $history.css("display", "none");
                    $login.css("display", "block");
                }
            }, "json");
        $logout.click(function () {
            $.get("/Pizza_war_exploded/User/logout",function () {
                location.reload();
            });
        });
    })
</script>
<header class="navbar-area" id="header">
    <nav class="navbar navbar-expand-lg">
        <div class="container nav-container">
            <div class="responsive-mobile-menu">
                <button class="menu toggle-btn d-block d-lg-none" data-target="#themefie_main_menu" aria-expanded="false" aria-label="Toggle navigation">
                    <span class="icon-left"></span>
                    <span class="icon-right"></span>
                </button>
            </div>
            <div class="collapse navbar-collapse" id="themefie_main_menu">
                <ul class="navbar-nav menu-open">
                    <li>
                        <a href="index.html">主页</a>
                    </li>
                    <li class="current-menu-item menu-item-has-children">
                        <a href="#">业务</a>
                        <ul class="sub-menu ps-0">
                            <li><a href="blog.html">历史订单</a></li>
                            <li><a href="menu.html?diff_id=3">分类菜单</a></li>
                            <li><a href="cart.html">购物车</a></li>
                            <li><a href="checkout.html">订单详情</a></li>
                            <li><a href="address-list.html">收货地址</a></li>
                        </ul>
                    </li>
                    <li>
                        <a href="about.html">关于我们</a>
                    </li>
                    <li>
                        <a href="contact.html">加盟方式</a>
                    </li>
                </ul>
            </div>
            <div class="logo">
                <a class="main-logo" href="index.html"><img src="static/picture/logo.png" alt="img"></a>
            </div>
<!--            <div class="nav-right-part nav-right-part-mobile">
                <ul>
                    <li><a class="search" href="#"><i class="ri-search-line"></i></a>
                    </li>
                    <li class="phone-contact d-md-block d-none"><i class="ri-phone-fill float-start"></i>
                        +123 456 789 000
                    </li>
                    <li class="loginName"></li>
                    <li class="menu-cart"><a href="cart.html">购物车 <span class="count"></span></a></li>
                    <li class="historyOrder">历史订单</li>
                    <li id="t_prise"></li>
                    <li class="login"><a href="login.html">登录</a></li>
                    <li class="register"><a href="register1.html">注册</a></li>
                    <li><a class="logout" href="javascript:void(0);">退出</a></li>
                </ul>
            </div>-->
            <div class="nav-right-part nav-right-part-desktop">
                <ul>
                    <li><a class="search" href="#"><i class="ri-search-line"></i></a>
                    </li>
                    <li class="phone-contact"><i class="ri-phone-fill float-start"></i>
                        +123 456 789 000
                    </li>
                    <li class="loginName">hhh</li>
                    <li class="menu-cart"><a href="cart.html">购物车 <span class="count"></span></a></li>
                    <li class="historyOrder"><a href="blog.html">历史订单</a></li>
                    <li class="login"><a href="login.html">登录</a></li>
                    <li class="register"><a href="register1.html">注册</a></li>
                    <li><a class="logout" href="javascript:void(0);">退出</a></li>
                </ul>
            </div>
        </div>
    </nav>
</header>
